<template>
	<view>
		<!-- 顶部卡片 -->
		<view style="padding: 20rpx;">
			<view class="devInfoBox" @click="navigateTo('/packageMine/deviceModify/index?deviceData=' + JSON.stringify(deviceData))">
				<view style="width: 100%;" class="flex">
					<image class="devImg" :src="deviceData.ico ? deviceData.ico : '/static/images/images23.png'" @error="imageError(index)" />
					<view class="devContent" style="position: relative;">
						<view style="font-size: 32rpx;">{{ deviceData.name ? deviceData.name : '' }}</view>
						<view>类型：{{ deviceData.productName ? deviceData.productName : '' }}</view>
						<view>编号：{{ deviceData.id ? deviceData.id : '' }}</view>
						<view style="width: 100%;position: absolute;left: 0;bottom: 0;right: 0;" class="flex aic">
							<image class="devStateImg" mode="widthFix" src="@/static/img/ico_jilu.png" />
							<image class="devStateImg" mode="widthFix" src="@/static/img/ico_yuancheng.png" style="margin-left: 20rpx;" />
							<view style="margin-left: 20rpx;">
								<image class="devStateImg" mode="widthFix" v-if="xinhaoNum > 0 && xinhaoNum <= 8" src="@/static/images/images27.png" />
								<image class="devStateImg" mode="widthFix" v-if="xinhaoNum > 8 && xinhaoNum <= 16" src="@/static/images/images26.png" />
								<image class="devStateImg" mode="widthFix" v-if="xinhaoNum > 16 && xinhaoNum <= 24" src="@/static/images/images25.png" />
								<image class="devStateImg" mode="widthFix" v-if="xinhaoNum > 24 && xinhaoNum <= 31" src="@/static/images/images24.png" />
								<image class="devStateImg" mode="widthFix" v-else src="@/static/images/images28.png" />
							</view>
							<view class="airState" style="margin-left: 20rpx;">优</view>
							<view style="margin-left: 20rpx;">在线</view>
						</view>
					</view>
				</view>
				<!-- <view class="bannerList_Box" @click="navigateTo('/packageMine/deviceModify/index?deviceData=' + JSON.stringify(deviceData))">
					<view class="listBox" style="width: 30%;">
						<image :src="deviceData.ico ? deviceData.ico : '/static/images/images23.png'" class="listIcon" @error="imageError(index)" />
					</view>
					<view class="listBox" style="width: 70%;">
						<view class="listBoxText1" style="padding-left: 26rpx;padding-top: 18rpx;">
							<view>
								<view class="listBoxText_Title" style="margin-bottom: 6rpx;">{{ deviceData.name ? deviceData.name : '' }}</view>
								<view class="listBoxText_serial" style="margin-bottom: 6rpx;">编号：{{ deviceData.id ? deviceData.id : '' }}</view>
							</view>
							<view class="typeClass" style="margin-bottom: 6rpx;" v-if="isViewData.product.productName">类型：{{ isViewData.product.productName }}</view>
							<span class="fenxiangSpan" @click.stop="navigateTo('/packageMine/details/shareDevice')"></span>
							<view style="width: 40rpx;">
								<image class="IconZaiXian" mode="widthFix" v-if="xinhaoNum > 0 && xinhaoNum <= 8" src="@/static/images/images27.png" />
								<image class="IconZaiXian" mode="widthFix" v-if="xinhaoNum > 8 && xinhaoNum <= 16" src="@/static/images/images26.png" />
								<image class="IconZaiXian" mode="widthFix" v-if="xinhaoNum > 16 && xinhaoNum <= 24" src="@/static/images/images25.png" />
								<image class="IconZaiXian" mode="widthFix" v-if="xinhaoNum > 24 && xinhaoNum <= 31" src="@/static/images/images24.png" />
								<image class="IconZaiXian" mode="widthFix" v-else src="@/static/images/images28.png" />
								<span v-if="xinhaoNum > 60" class="numDiv numDiv1">{{ xinhaoNum }}</span>
								<span v-if="xinhaoNum > 30 && xinhaoNum <= 60" class="numDiv numDiv2">{{ xinhaoNum }}</span>
								<span v-if="xinhaoNum >= 0 && xinhaoNum <= 30" class="numDiv numDiv3">{{ xinhaoNum }}</span>
							</view>
						</view>
					</view>
				</view> -->
			</view>
		</view>
		<!-- 切换栏 -->
		<view style="padding: 0 10rpx;margin-bottom: 18rpx;width: 100%;">
			<cc-scrollTag ref="ccTag" @tabChange="tabChange" :tagsList="tagList" bgColor="#FFFFFF"></cc-scrollTag>
		</view>
		<!-- 切换页 -->
		<swiper class="swiper" style="height: calc(100vh - 336rpx);" @change="changeSwiper" :current="btnnum">
			<swiper-item v-if="0"><iframe src="https://www.baidu.com"></iframe></swiper-item>
			<swiper-item v-if="isViewData.isView == 1">
				<!-- 物联测控 -->
				<view class="swiper-item">
					<view class="measureBox" style="height: calc(100vh - 476rpx);">
						<view class="measureHeader">
							<view class="measureLeft measureImg1" @click="ctrlAll('true')"></view>
							<view class="measureLeft measureImg2" @click="ctrlAll('false')"></view>
							<view class="measureLeft measureImg3" @click="getDianDevice()"></view>
							<!-- <view class="measureRight measureImg4"></view>
							<view class="measureRight measureImg5"></view>
							<view class="measureRight measureImg6"></view> -->
						</view>

						<view class="measureContent">
							<!-- <view class="contentList" v-for="(item,index) in iotData" :key="index">
								<span class="contentSpan display" style="top: 30rpx;">{{item.name}}</span>
								<span class="buttonSpan display openButton" v-if="item.value=='true'"></span>
								<span class="buttonSpan display closeButton" v-else></span>
								<span class="anSpan display">{{item.regData}}{{item.unit}}</span>
								<span class="openSpan display" @click="openIot(item)">
									<span class="iconSpan display icon1"></span>
									开
								</span>
								<span class="openSpan display" style="left: 66%;" @click="closeIot(item)">
									<span class="iconSpan display icon2"></span>
									关
								</span>
								<span class="openSpan display" style="left: 85%;letter-spacing: 2rpx;padding: 10rpx 0rpx 0rpx 44rpx;" @click="pointClick(item)">
									<span class="iconSpan display icon3" style="margin-right: 6;left: 14rpx;"></span>
									点动
								</span>
							</view> -->
							<view v-show="showMC">
								<view class="contentList" v-for="(item, index) in iotData" :key="index">
									<view class="boxLeft boxView">
										<span class="boxImg1Open" v-if="item.value == 'true'"></span>
										<span class="boxImg1Close" v-else></span>
										<span class="boxText typeClass">{{ item.name }}</span>
										<span class="boxImg2Open" v-if="item.oc == 'true'"></span>
										<span class="boxImg2Close" v-else></span>
										<span class="boxAn" v-if="item.regData != ''">{{ item.regData }}{{ item.unit }}</span>
									</view>
									<view class="boxRight boxView">
										<!-- <span class="boxRightSpan display" @click="openIot(item)">
											<span class="boxImgSpan display icon1"></span>
											开
										</span>
										
										<span class="boxRightSpan display" style="left: 68.5%;" @click="closeIot(item)">
											<span class="boxImgSpan display icon2"></span>
											关
										</span>
										<span class="boxRightSpan display"
											style="left: 85%;letter-spacing: 2rpx;padding: 16rpx 0rpx 0rpx 34rpx;" @click="pointClick(item)">
											<span class="boxImgSpan display icon3" style="left: 6%;"></span>
											点动
										</span> -->
										<view class="boxRightSpan display" @click="openIot(item)"><image src="@/static/images/组1.png" /></view>
										<view class="boxRightSpan display" @click="closeIot(item)"><image src="@/static/images/组2.png" /></view>
										<view class="boxRightSpan display" @click="pointClick(item)"><image src="@/static/images/组3.png" /></view>
									</view>
								</view>
							</view>

							<!-- <view class="contentList">
								<view class="boxLeft boxView">
									<span class="boxImg1Close"></span>
									<span class="boxText">继电器1</span>
									<span class="boxImg2Open"></span>
									<span class="boxAn">10.2A</span>
								</view>
								<view class="boxRight boxView">
									<span class="boxRightSpan display" @click="openIot(item)">
										<span class="boxImgSpan display icon1"></span>
										开
									</span>
									<span class="boxRightSpan display" style="left: 68.5%;" @click="openIot(item)">
										<span class="boxImgSpan display icon2"></span>
										关
									</span>
									<span class="boxRightSpan display" style="left: 85%;letter-spacing: 2rpx;padding: 16rpx 0rpx 0rpx 34rpx;" @click="openIot(item)">
										<span class="boxImgSpan display icon3" style="left: 6%;"></span>
										点动
									</span>
								</view>
							</view> -->

							<!-- <view class="contentList ">
								<span class="contentSpan display" style="top: 30rpx;">开关1</span>
								<span class="buttonSpan display openButton"></span>
								<span class="anSpan display">10.2A</span>
								<span class="openSpan display">
									<span class="iconSpan display icon1"></span>
									开
								</span>
								<span class="openSpan display" style="left: 66%;">
									<span class="iconSpan display icon2"></span>
									关
								</span>
								<span class="openSpan display" style="left: 85%;letter-spacing: 2rpx;padding: 10rpx 0rpx 0rpx 44rpx;">
									<span class="iconSpan display icon3" style="margin-right: 6;left: 14rpx;"></span>
									点动
								</span>
							</view> -->
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 数据采集 -->
				<view class="swiper-item" style="padding-top: 10rpx;">
					<template v-if="showColl">
						<view class="device-list" v-for="(item, index) in collectionList" :key="index" @click="collectionClick(item)">
							<view class="vtxt shadow">
								<view class="vtxtTitle">
									<image class="vtxtTitle-img" :src="imgUrlList1[index % 6]" />
									<view style="margin-left: 10rpx;">{{ item.name }}</view>
								</view>
								<view class="vtxtNum" v-if="item.type == 'Bool'">
									<!-- <switch class="blue" :checked="item.value" disabled style="transform: scale(0.7)" /> -->
									{{ item.value == true ? '开' : '关' }}
								</view>
								<view class="vtxtNum" v-else-if="item.type == 'UInt16' || item.type == 'Float32'">
									{{ item.value ? parseFloat(item.value).toFixed(1) : '0' }}{{ item.unit ? item.unit : '' }}
								</view>
								<view class="vtxtImg">
									<!-- <image style="width: 100%;height: 100%;" :src="imgUrlList2[index%6]"  /> -->
									<image
										v-if="item.rw == true && item.type == 'Bool'"
										style="width: 100%;height: 100%;"
										:src="item.ico ? item.ico : '../../../static/images/images87.png'"
									/>
									<image
										v-if="item.rw == false && item.type == 'Bool'"
										style="width: 100%;height: 100%;"
										:src="item.ico ? item.ico : '../../../static/images/images85.png'"
									/>
									<image
										v-if="item.type == 'UInt16' || item.type == 'Float32'"
										style="width: 100%;height: 100%;"
										:src="item.ico ? item.ico : '../../../static/images/images86.png'"
									/>
								</view>
								<view style="position: absolute;bottom: -10%;left: 0;" v-if="item.type == 'UInt16' || item.type == 'Float32'">
									<f2-echarts :dataList="item.staseList" />
								</view>
								<view class="vtxtList" style="overflow-y:scroll" v-else-if="item.type == 'Bool'">
									<view class="vtxtList_left">
										<span class="vyxt1" v-for="(list, num) in item.staseList" :key="num">
											<span>{{ list.time.substr(11, 8) }}</span>
											<span>{{ list.data == true ? '开' : '关' }}</span>
										</span>
									</view>
									<!-- <view class="vtxtList_left">
										<span v-for="(list,num) in item.staseList" :key="num">{{list.data==true?'开':'关'}}</span>
									</view> -->
								</view>
								<min-max
									v-if="item.type == 'UInt16' || item.type == 'Float32'"
									style="margin-top: 30rpx;"
									:min="-50"
									:max="350"
									:value="parseFloat(item.value)"
									:unit="item.unit"
								/>
							</view>
						</view>
					</template>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 远程控制 -->
				<view class="swiper-item" style="padding-top: 10rpx;">
					<view class="controlList flex shadow" v-for="(item, index) in iotData" :key="index">
						<image class="imgLeft" src="@/static/images/images38.png" />
						<view style="width: calc(100% - 135rpx);position: relative;">
							<view class="flex aic jcb">
								<view>{{ item.name }}</view>
								<!-- <span v-if="item.value == 'true'" class="rightTopThree rightTopThree2">打开</span>
								<span v-if="item.value == 'false'" class="rightTopThree rightTopThree1">关闭</span> -->
								<view style="height: 60rpx;">
									<switch class="blue" style="transform: scale(0.7);" :checked="item.value == 'true'" @change="clickControl(item, index)" />
									<view v-if="false" style="width: 180rpx;" class="flex">
										<image src="../../static/img/kongzhi_shang.png" style="width: 60rpx;height: 60rpx;" />
										<image src="../../static/img/ico_close.png" style="width: 60rpx;height: 60rpx;" />
										<image src="../../static/img/kongzhi_xia.png" style="width: 60rpx;height: 60rpx;" />
									</view>
								</view>
							</view>
							<view class="flex aic jcb" style="position: absolute;bottom: 0;left: 0;right: 0;">
								<view>
									状态：
									<span v-if="item.value == 'true'">打开</span>
									<span v-if="item.value == 'false'">关闭</span>
								</view>
								<span>回检：无</span>
								<!-- <span class="comentButton" v-if="item.datatype.type == 'enum'">
									<span
										class="buttonList buttomImg1"
										v-for="(list, num) in item.datatype.enumList"
										:key="num"
										:style="{ background: 'url(' + list.img + ') no-repeat', backgroundSize: '100% 100%' }"
										@click="clickControl(item)"
									></span>
									<span class="buttonList buttomImg2"></span>
									<span class="buttonList buttomImg3"></span>
								</span>
								<span class="comentButton">
									<span class="buttonList buttomImg4"></span>
									<span class="buttonList buttomImg2"></span>
									<span class="buttonList buttomImg5"></span>
								</span> -->
							</view>
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 参数配置 -->
				<view style="padding: 10rpx 30rpx;">
					<view class="shadow radius flex aic jcb" style="padding: 20rpx;margin-bottom: 20rpx;background: #fff;" v-for="(item, index) in list" :key="index">
						<image src="@/static/images/images9.png" style="width: 100rpx;height: 100rpx;margin-right: 20rpx;" />
						<view style="width: calc(100% - 120rpx - 3.5em);">
							<view style="font-weight: 600;color: #000;">{{ item.name }}：</view>
							<view class="flex aie" style="height: 80rpx;">
								<view v-if="item.type == 0" style="width: 100%;">
									<slider
										:value="item.value"
										:min="item.min"
										:max="item.max"
										:step="1"
										:block-size="18"
										block-color="#69D1C8"
										@changing="sliderChange($event, index)"
									></slider>
									<view class="flex jcb" style="padding: 0 20rpx;">
										<view>{{ item.min }}{{ item.unit }}</view>
										<view>{{ item.value }}</view>
										<view>{{ item.max }}{{ item.unit }}</view>
									</view>
								</view>
								<view v-if="item.type == 1" class="flex aie">
									<view>数值：</view>
									<input v-model="item.value" type="number" class="cspzInput" style="width: calc(100% - 3.5em);" />
								</view>
								<view v-if="item.type == 2" class="flex aie" style="width: 100%;">
									<uni-data-checkbox v-model="item.value" mode="tag" :localdata="item.typeList"></uni-data-checkbox>
								</view>
							</view>
						</view>
						<view style="width: 3em;text-align: center;">
							<button style="width: 3em;padding: 0;margin: 0;" type="primary" size="mini">保存</button>
							<button style="width: 3em;padding: 0;margin: 0;margin-top: 20rpx;" type="primary" size="mini">读取</button>
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item v-if="false">
				<!-- 设备分享 -->
				<view class="swiper-item">
					<uni-search-bar
						placeholder="请输入好友名称"
						style="width: 100%;"
						v-model="searchValue"
						@confirm="search"
						:focus="true"
						@input="input"
						@cancel="cancel"
					></uni-search-bar>
					<template v-if="isViewData.permissions.owner == true">
						<view class="FenXiangBox" style="height: calc(100vh - 692rpx);">
							<view class="peopleList" v-for="(item, index) in userDeviceList" :key="index">
								<view class="peopleLeft FenXiangs"><image :src="item.icon ? item.icon : '../../static/images/images45.png'" class="userIcon" /></view>
								<view class="peopleMiddle FenXiangs">{{ item.username }}</view>
								<view class="peopleRight FenXiangs">
									<!-- <view class="peopleButton" @click="navigateTo('/packageMine/details/limits')">
										权限设置
									</view> -->
									<view class="peopleButton" v-if="isViewData.permissions.owner == true" @click="settingsButton(item)">权限设置</view>
								</view>
							</view>
						</view>

						<button v-if="isViewData.permissions.owner == true" class="sharing" open-type="share"></button>
						<!-- <view style="display: inline-block;width: 100rpx;height: 50rpx;background-color: red;" @click="userUnbind()">
						
					</view> -->
						<view style="clear: both;"></view>
					</template>
					<view class="FenXiangBox circle" style="height: calc(100vh - 692rpx);" v-else>
						<view class="empty"></view>
						<view class="empty-text">没有分享权限</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 定时任务 -->
				<view style="padding: 10rpx 30rpx;">
					<view class="shadow radius" style="padding: 20rpx;margin-bottom: 20rpx;background: #fff;">
						<view class="flex jcb aic">
							<view class="flex" style="font-size: 30rpx;">
								<view style="font-weight: 600;color: #000;">定时任务1</view>
								<view class="cu-tag" style="margin-left: 20rpx;">运行中</view>
							</view>
							<view class="flex">
								<uni-icons type="compose" size="28" color="#2ABEAE"></uni-icons>
								<view style="margin: 0 10rpx;width: 1rpx;height: 100%;background: rgba(0,0,0,0.1);"></view>
								<uni-icons type="compose" size="28" color="#2ABEAE"></uni-icons>
								<view style="margin: 0 10rpx;width: 1rpx;height: 100%;background: rgba(0,0,0,0.1);"></view>
								<uni-icons type="trash" size="28" color="red"></uni-icons>
							</view>
						</view>
						<view style="margin: 10rpx 0;height: 1rpx;width: 100%;background: rgba(0,0,0,0.1);"></view>
						<view class="flex jcb">
							<view style="line-height: 1.9;">
								<view class="flex">
									<view class="title">类型：</view>
									<view>重复执行</view>
								</view>
								<view class="flex">
									<view class="title">时间：</view>
									<view>上午8：00</view>
								</view>
								<view class="flex">
									<view class="title">动作：</view>
									<view>启动1号继电器</view>
								</view>
							</view>
							<view style="width: 170rpx;height: 150rpx;text-align: center;padding-top: 20rpx;">
								<view
									class=""
									style="color: #000;margin: auto;width: 120rpx;height: 120rpx;border-radius: 50%;border: solid 1rpx #668887;line-height: 110rpx;font-weight: 600;font-size: 36rpx;"
								>
									52
								</view>
								<view class="title" style="background: white;overflow: hidden;margin-top: -40rpx;padding-bottom: 5rpx;">累计执行次数</view>
							</view>
						</view>
						<view class="flex aic">
							<view class="title">星期：</view>
							<view style="width: calc(100% - 4em);">
								<liu-checkBox
									class="weekButton"
									:checkOptions="weeks"
									:pointer="'none'"
									:marginRight="'8rpx'"
									:activeColor="'#3E73FE'"
								></liu-checkBox>
								<!-- <uni-data-checkbox mode="tag" multiple :wrap="false" :localdata="weeks"></uni-data-checkbox> -->
							</view>
						</view>
					</view>
					<view style="width: 100%;text-align: center;"><button type="primary" size="mini">添加定时任务</button></view>
				</view>
				<view class="swiper-item" v-if="0">
					<view
						class="tasksList"
						v-for="(item, index) in tasksList"
						:key="index"
						@click="navigateTo('/packageMine/details/editScheduled?jobItem=' + JSON.stringify(item) + '&deviceData=' + JSON.stringify(deviceData))"
					>
						<!-- <view class="tasksList" v-for="(item,index) in tasksList" :key="index"> -->
						<view class="tasksTitle">
							<view class="titleOne">{{ item.name }}</view>
							<view class="tasksDelete" @click.stop="deleteStatus(item.taskId)"></view>
						</view>
						<view class="xinxiList">
							<view class="xinxiList-title">执行时间</view>
							<view class="xinxiList-text">{{ item.startHour + ':' + item.startMinute }} - {{ item.stopHour + ':' + item.stopMinute }}</view>
						</view>
						<view class="xinxiList" style="width:630rpx;">
							<view class="xinxiList-title">星期选择</view>
							<view class="xinxiList-text" style="width: 470rpx;">
								<liu-checkBox
									class="weekButton"
									:checkOptions="item.weeks"
									:pointer="'none'"
									:marginRight="'8rpx'"
									:activeColor="'#3E73FE'"
								></liu-checkBox>
							</view>
						</view>
						<view class="xinxiList" style="width:630rpx;">
							<view class="xinxiList-title">执行动作</view>
							<view class="xinxiList-text zhixingSub">
								<mftcc-select
									disabled
									class="linkageSelect"
									style="width: 160rpx;"
									:value="item.addr + ''"
									:paddingLeft="'0rpx'"
									:border="'none'"
									:hight="40"
									:fsize="'26rpx'"
									align="left"
									name="addr"
									:dataList="cacheList"
									text="name"
									@change="staseChange($event, index)"
								/>
							</view>
						</view>
						<view v-if="item.enable == false" class="dingshiStatus">已关闭</view>
						<view v-if="item.enable == true" class="dingshiStatus" style="background-color: #3E73FE;">已开启</view>
						<!-- <switch class="tasksSwitch blue" :checked="item.enable" disabled /> -->
						<!-- <switch class="tasksSwitch blue" :checked="item.enable" @change.stop="tasksChange(item)" /> -->
						<!-- <view class="accumulate">
							<view class="accumulateTop">
								{{item.jobCount == null?'0' : item.jobCount}}
							</view>
							累计执行
						</view> -->
					</view>
					<view class="tasksButton">
						<view class="submitButton" @click="navigateTo('/packageMine/details/addScheduled?deviceData=' + JSON.stringify(deviceData))">
							添加定时任务
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 自动任务 -->
				<view class="swiper-item">
					<view
						class="tasksList"
						v-for="(item, index) in tasksList"
						:key="index"
						@click="navigateTo('/packageMine/details/editScheduled?jobItem=' + JSON.stringify(item) + '&deviceData=' + JSON.stringify(deviceData))"
					>
						<!-- <view class="tasksList" v-for="(item,index) in tasksList" :key="index"> -->
						<view class="tasksTitle">
							<view class="titleOne">{{ item.name }}</view>
							<view class="tasksDelete" @click.stop="deleteStatus(item.taskId)"></view>
						</view>
						<view class="xinxiList">
							<view class="xinxiList-title">执行时间</view>
							<view class="xinxiList-text">{{ item.startHour + ':' + item.startMinute }} - {{ item.stopHour + ':' + item.stopMinute }}</view>
						</view>
						<view class="xinxiList" style="width:630rpx;">
							<view class="xinxiList-title">星期选择</view>
							<view class="xinxiList-text" style="width: 470rpx;">
								<liu-checkBox
									class="weekButton"
									:checkOptions="item.weeks"
									:pointer="'none'"
									:marginRight="'8rpx'"
									:activeColor="'#3E73FE'"
								></liu-checkBox>
							</view>
						</view>
						<view class="xinxiList" style="width:630rpx;">
							<view class="xinxiList-title">执行动作</view>
							<view class="xinxiList-text zhixingSub">
								<mftcc-select
									disabled
									class="linkageSelect"
									style="width: 160rpx;"
									:value="item.addr + ''"
									:paddingLeft="'0rpx'"
									:border="'none'"
									:hight="40"
									:fsize="'26rpx'"
									align="left"
									name="addr"
									:dataList="cacheList"
									text="name"
									@change="staseChange($event, index)"
								/>
							</view>
						</view>
						<view v-if="item.enable == false" class="dingshiStatus">已关闭</view>
						<view v-if="item.enable == true" class="dingshiStatus" style="background-color: #3E73FE;">已开启</view>
						<!-- <switch class="tasksSwitch blue" :checked="item.enable" disabled /> -->
						<!-- <switch class="tasksSwitch blue" :checked="item.enable" @change.stop="tasksChange(item)" /> -->
						<!-- <view class="accumulate">
							<view class="accumulateTop">
								{{item.jobCount == null?'0' : item.jobCount}}
							</view>
							累计执行
						</view> -->
					</view>
					<view class="tasksButton">
						<view class="submitButton" @click="navigateTo('/packageMine/details/addScheduled?deviceData=' + JSON.stringify(deviceData))">
							添加定时任务
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 联动控制 -->
				<view style="padding: 10rpx 30rpx;">
					<view class="shadow radius" style="padding: 20rpx;margin-bottom: 20rpx;background: #fff;">
						<view class="flex jcb aic">
							<view class="flex" style="font-size: 30rpx;">
								<view style="font-weight: 600;color: #000;">定时任务1</view>
								<view class="cu-tag" style="margin-left: 20rpx;">运行中</view>
							</view>
							<view class="flex">
								<uni-icons type="compose" size="28" color="#2ABEAE"></uni-icons>
								<view style="margin: 0 10rpx;width: 1rpx;height: 100%;background: rgba(0,0,0,0.1);"></view>
								<uni-icons type="compose" size="28" color="#2ABEAE"></uni-icons>
								<view style="margin: 0 10rpx;width: 1rpx;height: 100%;background: rgba(0,0,0,0.1);"></view>
								<uni-icons type="trash" size="28" color="red"></uni-icons>
							</view>
						</view>
						<view style="margin: 10rpx 0;height: 1rpx;width: 100%;background: rgba(0,0,0,0.1);"></view>
						<view class="flex jcb" style="position: relative;">
							<view style="line-height: 1.9;">
								<view>
									<view style="color: #000;font-weight: 600;">条件：</view>
									<view class="flex">
										<view style="margin-right: 10rpx;">当：</view>
										<view style="margin-right: 10rpx;">空气温度</view>
										<view style="margin-right: 10rpx;">大于</view>
										<view style="margin-right: 10rpx;">35</view>
									</view>
									<view class="flex">
										<view style="margin-right: 10rpx;">当：</view>
										<view style="margin-right: 10rpx;">空气湿度</view>
										<view style="margin-right: 10rpx;">大于</view>
										<view style="margin-right: 10rpx;">50</view>
									</view>
								</view>
								<view>
									<view style="color: #000;font-weight: 600;">动作：</view>
									<view class="flex">
										<view style="margin-right: 10rpx;">设备A</view>
										<view style="margin-right: 10rpx;">1号闸门</view>
										<view style="margin-right: 10rpx;">开启</view>
									</view>
									<view class="flex">
										<view style="margin-right: 10rpx;">设备B</view>
										<view style="margin-right: 10rpx;">2号闸门</view>
										<view style="margin-right: 10rpx;">开启</view>
									</view>
								</view>
							</view>
							<view style="width: 190rpx;height: 150rpx;text-align: center;padding-top: 20rpx;position: absolute;top: calc(50% - 150rpx / 2);right: 0;">
								<view
									class=""
									style="color: #000;margin: auto;width: 120rpx;height: 120rpx;border-radius: 50%;border: solid 1rpx #668887;line-height: 110rpx;font-weight: 600;font-size: 36rpx;"
								>
									52
								</view>
								<view class="title" style="background: white;overflow: hidden;margin-top: -40rpx;padding-bottom: 5rpx;font-size: 26rpx;">
									一周内累计执行
								</view>
							</view>
						</view>
					</view>
					<view style="width: 100%;text-align: center;"><button type="primary" size="mini">添加联动控制</button></view>
				</view>
				<view class="swiper-item" v-if="0">
					<view class="linkageList" v-for="(item, index) in sceneList" :key="index">
						<view class="linkageTitle">
							<image class="linkageOne" src="@/static/images/images32.png" />
							<view class="linkageTwo">{{ item.sceneName }}</view>
							<view class="linkageThree linkageDai">待机</view>
						</view>
						<view class="linkageContent" style="margin-bottom: 10rpx;">
							条件：当
							<mftcc-select
								class="linkageSelect"
								style="margin-left: 10rpx;width: 140rpx;"
								:hight="40"
								:fsize="'26rpx'"
								align="left"
								name="value"
								:dataList="staseOptions"
								text="text"
								@change="staseChange"
							/>
							<span style="margin-left: 30rpx;margin-right: 30rpx;">大于</span>
							<mftcc-select
								class="linkageSelect"
								style="width: 140rpx;"
								:hight="40"
								:fsize="'26rpx'"
								align="left"
								name="value"
								:dataList="warmOptions"
								text="text"
								@change="staseChange"
							/>
						</view>
						<view class="linkageContent">
							动作：则
							<mftcc-select
								class="linkageSelect"
								style="margin-left: 10rpx;width: 140rpx;"
								:hight="40"
								:fsize="'26rpx'"
								align="left"
								name="value"
								:dataList="deviceOptions"
								text="text"
								@change="staseChange"
							/>
							<mftcc-select
								class="linkageSelect"
								style="margin-left: 112rpx;width: 140rpx;"
								:hight="40"
								:fsize="'26rpx'"
								align="left"
								name="value"
								:dataList="openOptions"
								text="text"
								@change="staseChange"
							/>
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 历史数据s -->
				<view class="swiper-item"><historyList :deviceId="deviceId" style="width: 100%;"></historyList></view>
			</swiper-item>
			<swiper-item>
				<!-- 设备分析 -->
				<view style="padding: 10rpx 30rpx;">
					<view class="stateRound">优</view>
					<view class="flex aic jcb border radius" style="padding: 10rpx 20rpx;" @click="toChart">
						<view style="width: 7em;">固件版本号：</view>
						<view class="border" style="flex:1;width: 7em;padding: 8rpx 10rpx;margin-right: 10rpx;">V1.0.1</view>
						<uni-icons type="checkbox" size="24"></uni-icons>
						<view style="width: 3em;text-align: center;">正常</view>
						<uni-icons type="right" size="22"></uni-icons>
					</view>
					<view style="width: 100%;text-align: center;margin-top: 20rpx;"><button size="mini" type="primary">一键检测</button></view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 通知日志 -->
				<view class="swiper-item">
					<view class="alarm">
						<view class="alarmBox" @click="alarmClick('3')">
							<view><image class="alarmBox-img" src="@/static/images/images49.png" /></view>
							故障
						</view>
						<view class="alarmBox" @click="alarmClick('1')">
							<view><image class="alarmBox-img" src="@/static/images/images52.png" /></view>
							预警
						</view>
						<view class="alarmBox" @click="alarmClick('2')">
							<view><image class="alarmBox-img" src="@/static/images/images54.png" /></view>
							异常
						</view>
						<view class="alarmBox" @click="alarmClick('4')">
							<view><image class="alarmBox-img" src="@/static/images/images56.png" /></view>
							操作
						</view>
					</view>

					<scroll-view
						class="alarmList"
						scroll-y="true"
						refresher-enabled="true"
						:refresher-triggered="triggered"
						style="height: calc(100vh - 624rpx);"
						@refresherrefresh="onRefresh"
						@refresherrestore="onRestore"
						@refresherabort="onAbort"
						@scrolltolower="scrollAlarm"
					>
						<view class="alarms" v-for="(item, index) in alarmList" :key="index">
							<image v-if="item.alert_level == 1" class="alarms-img" src="@/static/images/images59.png" />
							<image v-if="item.alert_level == 2" class="alarms-img" src="@/static/images/images58.png" />
							<image v-if="item.alert_level == 3" class="alarms-img" src="@/static/images/images57.png" />
							<image v-if="item.alert_level == 4" class="alarms-img" src="@/static/images/images60.png" />
							<span v-if="item.alert_level == 1" style="margin-right: 40rpx;">预警</span>
							<span v-if="item.alert_level == 2" style="margin-right: 40rpx;">异常</span>
							<span v-if="item.alert_level == 3" style="margin-right: 40rpx;">故障</span>
							<span v-if="item.alert_level == 4" style="margin-right: 40rpx;">操作</span>
							<span>
								{{
									item.create_time
										.toLocaleString()
										.replace(/T/g, ' ')
										.replace(/\.[\d]{3}Z/, '')
								}}
							</span>
							<span style="margin-right: 40rpx;display: block;margin-top: 10rpx;">{{ item.message }}</span>
						</view>
						<view v-if="alarmList.length == 0" style="text-align: center;padding-top: 50rpx;"><view>无预警通知！</view></view>
						<!-- <view class="alarms">
							<image class="alarms-img" src="@/static/images/images57.png" />
							<span style="margin-right: 40rpx;">故障</span>
							<span style="margin-right: 40rpx;">电源电压供电异常</span>
							<span>2023-11-1 10:07:11</span>
						</view>

						<view class="alarms">
							<image class="alarms-img" src="@/static/images/images58.png" />
							<span style="margin-right: 40rpx;">故障</span>
							<span style="margin-right: 40rpx;">电源电压供电异常</span>
							<span>2023-11-1 10:07:11</span>
						</view>

						<view class="alarms">
							<image class="alarms-img" src="@/static/images/images59.png" />
							<span style="margin-right: 40rpx;">故障</span>
							<span style="margin-right: 40rpx;">电源电压供电异常</span>
							<span>2023-11-1 10:07:11</span>
						</view>

						<view class="alarms">
							<image class="alarms-img" src="@/static/images/images60.png" />
							<span style="margin-right: 40rpx;">故障</span>
							<span style="margin-right: 40rpx;">电源电压供电异常</span>
							<span>2023-11-1 10:07:11</span>
						</view> -->
					</scroll-view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 流量管理 -->
				<view style="padding: 10rpx 30rpx;">
					<view class="card">
						<view class="flex">
							<view style="line-height: 1.8;">
								<view class="flex">
									<view style="width: 5em;">ICCID：</view>
									<view>8888888888888888888</view>
								</view>
								<view class="flex">
									<view style="width: 5em;">运营商：</view>
									<view>中国移动</view>
								</view>
								<view class="flex">
									<view style="width: 5em;">流量套餐：</view>
									<view>100M/月</view>
								</view>
								<view class="flex">
									<view style="width: 5em;">到期时间：</view>
									<view>2026-02-31</view>
								</view>
								<view class="flex">
									<view style="width: 5em;">流量费用：</view>
									<view>20元/年</view>
								</view>
								<view class="flex">
									<view style="width: 5em;">账户余额：</view>
									<view>1000元</view>
								</view>
							</view>
							<view style="width: 200rpx;text-align: center;">
								<view class="dataRound">
									<view>
										<view style="font-size: 30rpx;font-weight: 600;">100M</view>
										<view>本月剩余流量</view>
									</view>
								</view>
								<button type="primary" size="mini">立即充值</button>
							</view>
						</view>
						<view class="flex aic">
							<view style="margin-right: 8rpx;">设备包含流量期限：</view>
							<view style="margin-right: 8rpx;">5年</view>
							<view style="margin-right: 8rpx;">截至：</view>
							<view style="margin-right: 8rpx;">2027-02-31</view>
						</view>
					</view>
				</view>
				<view class="swiper-item" v-if="0">
					<view class="trafficList" style="background: url('/static/images/images61.png') no-repeat;background-size: 100% 100%;">
						<view>
							<image class="trafficOne" src="@/static/images/images32.png" />
							<span class="trafficTwo">855156456485252</span>
							<view class="linkageThree trafficShiyong">使用中</view>
						</view>
						<view class="trafficMiddle">
							<view class="traMiddle">
								<view class="traMiddle1">10</view>
								月流量(MB)
							</view>
							<view class="traMiddle" style="margin-left: 40rpx;margin-right: 40rpx;">
								<view class="traMiddle1">10.000</view>
								剩余流量(MB)
							</view>
							<view class="traMiddle">
								<view class="traMiddle1">10.000</view>
								已用流量(MB)
							</view>
						</view>
						<view class="trafficBottom">
							<span>到期日期：2024-11-1 24:00:00</span>
							<span class="trafficRecord">充值记录</span>
						</view>
					</view>
				</view>
			</swiper-item>
			<swiper-item>
				<!-- 定位轨迹 -->
				<view style="padding: 10rpx 30rpx;"></view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
// import { v4 } from 'uuid';
import { MQTT_IP, MQTT_OPTIONS } from '@/common/js/mqtt.js';
var mqtt = require('mqtt/dist/mqtt.js');
var client;
// import mqtt from '@/common/js/mqtt.min.js'
// console.log('mqtt')
// let mqtt = require('../../../common/js/mqtt.min.js')
// import mqtt from '../../../common/js/mqtt.min.js'
// console.log(mqtt)
// import * as echarts from "echarts";
// import F2 from '@/uni_modules/lime-f2/components/l-f2/f2.min.js';
// import F2Echarts from '@/packageMine/components/f2-echarts/f2-echarts.vue';
import historyList from './history.vue';
export default {
	components: { historyList },
	data() {
		const currentDate = this.getDate({
			format: true
		});
		return {
			// tagList: ['物联测控', '数据采集', '远程控制', '设备分享', '定时任务', '联动控制', '告警通知', '历史数据', '流量卡'],
			tagList: ['数据采集', '远程控制', '参数配置', '定时任务', '自动控制', '联动控制', '历史数据', '设备分析', '设备日志', '流量管理', '定位轨迹'],
			weeks: [
				{ name: '一', value: 1 },
				{ name: '二', value: 2 },
				{ name: '三', value: 3 },
				{ name: '四', value: 4 },
				{ name: '五', value: 5 },
				{ name: '六', value: 6 },
				{ name: '日', value: 7 }
			],
			showTag: false,
			btnnum: 0,
			searchValue: '',
			imgUrlList1: [
				'/static/images/images32.png',
				'/static/images/images63.png',
				'/static/images/images64.png',
				'/static/images/images65.png',
				'/static/images/images34.png',
				'/static/images/images36.png'
			],
			imgUrlList2: [
				'/static/images/images33.png',
				'/static/images/images66.png',
				'/static/images/images67.png',
				'/static/images/images68.png',
				'/static/images/images35.png',
				'/static/images/images37.png'
			],
			warmOptions: [
				{
					text: '33℃',
					value: '1'
				},
				{
					text: '34℃',
					value: '2'
				},
				{
					text: '35℃',
					value: '3'
				},
				{
					text: '36℃',
					value: '4'
				},
				{
					text: '37℃',
					value: '5'
				},
				{
					text: '38℃',
					value: '6'
				}
			],
			deviceOptions: [
				{
					text: '闸门2号',
					value: '1'
				}
			],
			staseOptions: [
				{
					text: '空气温度',
					value: '1'
				}
			],
			openOptions: [
				{
					text: '开启',
					value: '1'
				},
				{
					text: '关闭',
					value: '2'
				}
			],
			fades: ['fade'],
			starttime: currentDate,
			endtime: currentDate,
			data: [
				{
					time: '2016-08-08 00:00:00',
					tem: 10
				},
				{
					time: '2016-08-08 12:00:00',
					tem: 22
				},
				{
					time: '2016-08-08 23:00:00',
					tem: 16
				}
			],
			checkOptions1: [
				{
					id: 1,
					name: '一'
					// selected: true //回显传入
				},
				{
					id: 2,
					name: '二'
				},
				{
					id: 3,
					name: '三'
				},
				{
					id: 4,
					name: '四'
				},
				{
					id: 5,
					name: '五'
				},
				{
					id: 6,
					name: '六'
				},
				{
					id: 0,
					name: '日'
				}
			],
			checkOptions2: [
				{
					id: 1,
					name: '一',
					selected: true //回显传入
				},
				{
					id: 2,
					name: '二',
					selected: true
				},
				{
					id: 3,
					name: '三',
					selected: true
				},
				{
					id: 4,
					name: '四',
					selected: true
				},
				{
					id: 5,
					name: '五',
					selected: true
				},
				{
					id: 6,
					name: '六',
					selected: true
				},
				{
					id: 0,
					name: '日',
					selected: true
				}
			],
			checkOptions3: [],
			deviceId: '',
			deviceData: '',
			deviceType: '',
			collectionList: [],
			collectionListAddr: [],
			showColl: false,

			remoteList: [],
			userDeviceList: [],
			backupsuserList: [],
			keyword: '',
			tasksList: [],
			cacheList: [],
			alarm: '',
			alarmList: '',
			triggered: false,
			alarmTotal: 10,
			totals: '',
			alarmPageNum: 1,
			sceneList: [],
			connectInfo: {
				clientId: 1,
				username: '',
				password: '',
				clean: ''
			},
			// topic:"",
			topicReg: 'message/reg/' + MQTT_OPTIONS.clientId,
			topicStatus: 'message/status/' + MQTT_OPTIONS.clientId,
			iotData: [],
			iotRegData: [],
			iotOpenClose: [],
			showMC: false,

			fenxiangToken: '',
			userData: {},
			xinhaoNum: '',
			isViewData: {
				permissions: {}
			},

			number: 0,
			batteryTypeList: [
				{
					text: '干电池',
					value: 0
				},
				{
					text: '铅蓄电池',
					value: 1
				},
				{
					text: '锂电池',
					value: 2
				}
			],
			list: [
				{
					name: '定时采集周期',
					type: 0,
					value: 50,
					min: 0,
					max: 100,
					unit: 'ms'
				},
				{
					name: '定时采集周期',
					type: 1,
					value: 50,
					unit: 'ms'
				},
				{
					name: '电池类型',
					value: 2,
					type: 2,
					typeList: [
						{
							text: '干电池',
							value: 0
						},
						{
							text: '铅蓄电池',
							value: 1
						},
						{
							text: '锂电池',
							value: 2
						}
					]
				}
			]
		};
	},
	mounted() {
		
	},
	onShow() {
		this.userData = uni.getStorageSync('ddkUserInfo');
		this.getDianDevice();
		// this.getDeviceDetails()
		this.connect();
	},
	onLoad(option) {
		this.deviceId = option.id;
		this._freshing = false;
		setTimeout(() => {
			this.triggered = true;
		}, 1000);
	},
	onPullDownRefresh() {},
	onReady() {},
	onHide() {
		this.disconnect();
	},
	onUnload() {
		this.disconnect();
	},
	methods: {
		toChart() {
			uni.navigateTo({});
		},
		sliderChange(e, f) {
			this.list[f].value = e.detail.value;
		},
		ctrlAll(status) {
			if (!(client && client.connected)) {
				this.connect();
			}
			console.log(client.connected);
			if (this.isViewData.permissions.run) {
				this.$request(this.$urls.ctrlAll, 'post', { deviceId: this.deviceId, status: status }, this.$store.state.token)
					.then(response => {
						if (response.code == 200) {
							uni.showToast({
								icon: 'none',
								title: '成功'
							});
						} else {
							if (response.message == 'DEVICE_TIMEOUT') {
								uni.showToast({
									icon: 'none',
									title: '设备超时'
								});
							} else {
								uni.showToast({
									icon: 'none',
									title: response.message
								});
							}
						}
					})
					.catch(err => {
						this.log(err);
					});
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		pointClick(item) {
			if (!(client && client.connected)) {
				this.connect();
			}
			if (this.isViewData.permissions.run) {
				let that = this;
				if (item.value == 'true') {
					var postdata = {
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'false'
							}
						]
					};

					var postdata2 = {
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'true'
							}
						]
					};
				} else {
					var postdata = {
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'true'
							}
						]
					};

					var postdata2 = {
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'false'
							}
						]
					};
				}

				// console.log(postdata)
				// console.log(postdata2)

				this.$request(this.$urls.writeReg, 'post', postdata, this.$store.state.token)
					.then(response => {
						if (response.code == 200) {
						} else {
							if (response.message == 'DEVICE_TIMEOUT') {
								uni.showToast({
									icon: 'none',
									title: '设备超时'
								});
							} else {
								uni.showToast({
									icon: 'none',
									title: response.message
								});
							}
						}
					})
					.catch(err => {
						this.log(err);
					});

				setTimeout(function() {
					that.$request(that.$urls.writeReg, 'post', postdata2, that.$store.state.token)
						.then(response => {
							if (response.code == 200) {
								uni.showToast({
									icon: 'none',
									title: '成功'
								});
							} else {
								if (response.message == 'DEVICE_TIMEOUT') {
									uni.showToast({
										icon: 'none',
										title: '设备超时'
									});
								} else {
									uni.showToast({
										icon: 'none',
										title: response.message
									});
								}
							}
						})
						.catch(err => {
							this.log(err);
						});
				}, 2000);
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		openIot(item) {
			if (!(client && client.connected)) {
				this.connect();
			}
			if (this.isViewData.permissions.run) {
				this.$request(
					this.$urls.writeReg,
					'post',
					{
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'true'
							}
						]
					},
					this.$store.state.token
				)
					.then(response => {
						if (response.code == 200) {
							uni.showToast({
								icon: 'none',
								title: '成功'
							});
						} else {
							if (response.message == 'DEVICE_TIMEOUT') {
								uni.showToast({
									icon: 'none',
									title: '设备超时'
								});
							} else {
								uni.showToast({
									icon: 'none',
									title: response.message
								});
							}
						}
					})
					.catch(err => {
						this.log(err);
					});
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		closeIot(item) {
			if (!(client && client.connected)) {
				this.connect();
			}
			if (this.isViewData.permissions.run) {
				this.$request(
					this.$urls.writeReg,
					'post',
					{
						deviceId: this.deviceId,
						regs: [
							{
								type: 'Bool',
								addr: item.addr,
								value: 'false'
							}
						]
					},
					this.$store.state.token
				)
					.then(response => {
						if (response.code == 200) {
							uni.showToast({
								icon: 'none',
								title: '成功'
							});
						} else {
							if (response.message == 'DEVICE_TIMEOUT') {
								uni.showToast({
									icon: 'none',
									title: '设备超时'
								});
							} else {
								uni.showToast({
									icon: 'none',
									title: response.message
								});
							}
						}
					})
					.catch(err => {
						this.log(err);
					});
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		// 断开链接
		disconnect() {
			try {
				if (client && client.connected) {
					client.end();
				}
			} catch (error) {
				console.log(error);
			}
		},
		connect() {
			// MQTT_OPTIONS.clientId = v4()
			var that = this;
			// #ifdef H5
			client = mqtt.connect(
				'ws://' + MQTT_IP,
				MQTT_OPTIONS
			);
			// #endif
			// #ifdef MP-WEIXIN||APP-PLUS
			client = mqtt.connect(
				'wxs://' + MQTT_IP,
				MQTT_OPTIONS
			);
			// #endif
			client
				.on('connect', function() {
					// console.log('连接成功')
					client.subscribe(that.topicReg, function(err) {
						if (!err) {
							// console.log('订阅成功')
						}
					});
					client.subscribe(that.topicStatus, function(err) {
						if (!err) {
							// console.log('订阅成功11')
						}
					});
				})
				.on('reconnect', function(error) {
					// console.log('正在重连...', that.topicReg)
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '正在重连...'
					});
				})
				.on('error', function(error) {
					// console.log('连接失败...', error)
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '连接失败...'
					});
				})
				.on('end', function() {
					// console.log('连接断开')
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '连接断开...'
					});
				})
				.on('message', function(topic, message) {
					// console.log(topic, message)
					// console.log('接收推送信息：', message.toString())
					// console.log(topic)
					// console.log(new Date())
					if (topic == that.topicReg) {
						// console.log('接收推送信息：',  message.toString())
						let msg = JSON.parse(message.toString());
						if (msg.deviceId == that.deviceId) {
							console.log('接收推送信息111：', message.toString());
							// console.log(new Date())
							msg.regItems.forEach(function(item, index, arr) {
								that.iotData.forEach(function(item2, index2, arr2) {
									if (item2.addr == item.regAddr) {
										that.iotData[index2].value = item.regData;
									}
									if (item2.regDataAddr == item.regAddr) {
										that.iotData[index2].regData = parseFloat(item.regData).toFixed(1);
									}

									if (item2.ocAddr == item.regAddr) {
										that.iotData[index2].oc = item.regData;
									}
								});

								that.collectionList.forEach(function(item2, index2, arr2) {
									if (item2.addr == item.regAddr) {
										that.collectionList[index2].value = parseFloat(item.regData).toFixed(1);
									}
								});

								/* that.remoteList.forEach(function(item2, index2, arr2) {
									if (item2.addr + 20 == item.regAddr) {
										that.remoteList[index2].regData = item.regData
										console.log("remoteList")
										console.log(item)
										// that.iotData[index2].unit = (typeof item.unit==undefined||typeof item2.unit=='undefined')?"":item2.unit
										// return;
									}
									if (item2.addr == item.regAddr) {
										that.remoteList[index2].value = item.regData
										// that.iotData[index2].unit = (typeof item.unit==undefined||typeof item2.unit=='undefined')?"":item2.unit
										// return;
									}
								}) */
							});
							that.$forceUpdate();
							// console.log(that.iotData)
						}
					}
				});
		},
		/* test() {
				// MQTT_OPTIONS.clientId = v4()
				var that = this
				// #ifdef H5
				client = mqtt.connect('ws://' + MQTT_IP, MQTT_OPTIONS)
				// #endif
				// #ifdef MP-WEIXIN||APP-PLUS
				client = mqtt.connect('wxs://' + MQTT_IP, MQTT_OPTIONS)
				// #endif
				client.on('connect', function() {
					console.log('连接成功')
				
					client.subscribe(that.topicStatus, function(err) {
						if (!err) {
							console.log('订阅成功11')
						}

					})
				}).on('reconnect', function(error) {
					console.log('正在重连...', that.topic)
				}).on('error', function(error) {
					console.log('连接失败...', error)
				}).on('end', function() {
					console.log('连接断开')
				}).on('message', function(topic, message) {
					// console.log(topic, message)
					console.log('接收推送信息：', message.toString())
					console.log(topic)
					console.log(new Date())
				})
			}, */
		navigateTo(url) {
			uni.navigateTo({ url: url });
		},
		imageError(e) {
			this.deviceData[e].ico = '@/static/images/images23.png';
		},
		tabChange(t) {
			// console.log("tab选择序列 = " + JSON.stringify(t));
			this.btnnum = JSON.stringify(t);
		},
		getDate(type) {
			const date = new Date();
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();

			if (type === 'start') {
				year = year - 60;
			} else if (type === 'end') {
				year = year + 2;
			}
			month = month > 9 ? month : '0' + month;
			day = day > 9 ? day : '0' + day;
			return `${year}-${month}-${day}`;
		},
		collectionClick(item) {
			if (this.isViewData.permissions.conf) {
				this.navigateTo('/packageMine/details/resources?resourcesData=' + JSON.stringify(item) + '&deviceId=' + this.deviceData.id);
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		//切换tab2
		changeSwiper(e) {
			this.btnnum = e.detail.current;
			console.log(this.btnnum);
			this.$refs.ccTag.setTags(this.tagList[this.btnnum], this.btnnum);
		},
		getDianDevice() {
			let that = this;
			let data = {};
			data.deviceId = this.deviceId;
			this.$request(this.$urls.getDianDevice, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.isViewData = response.data;
						if (!response.data.isView || response.data.isView == 0) {
							if (this.tagList.indexOf('物联测控') != -1) {
								this.tagList.shift();
							} else {
								this.tagList = [
									'数据采集',
									'远程控制',
									'参数配置',
									'定时任务',
									'自动控制',
									'联动控制',
									'历史数据',
									'设备分析',
									'设备日志',
									'流量管理',
									'定位轨迹'
								];
							}
						} else if (response.data.isView && response.data.isView == 1) {
							if (this.tagList.indexOf('物联测控') == -1) {
								this.tagList.unshift('物联测控');
							}
							// this.connect()
						}
						this.showTag = true;
						this.getDeviceDetails();

						this.getDeviceDataV2();
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		getDeviceDetails() {
			this.$request(this.$urls.getDeviceDetails + this.deviceId, 'get', {}, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.deviceData = response.data;
						this.getDingShiTasks();
						this.fenxiangClick();
						this.getDeviceData();
						this.getRemoteControl();
						this.getUserList();
						// this.getHistorySelect()
						this.getalarmList();
						this.getSceneList();
						this.deviceType = response.data.product.productName;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 获取数据采集
		getDeviceData() {
			this.collectionList = [];
			this.collectionListAddr = [];
			this.remoteList = [];
			// this.iotData = [];
			this.iotRegData = [];
			let data = {};
			data.deviceId = this.deviceData.id;
			// data.deviceId = this.deviceData.deviceId
			// if (this.deviceData.slaveId == null) {
			// 	this.deviceData.slaveId = ''
			// }
			// data.slaveId = this.deviceData.slaveId
			// this.$request(this.$urls.getAcquisition, 'get', data,
			// 	this.$store.state.token).then(response => {
			// 	if (response.code == 200) {
			// 		this.collectionList = response.data;
			// 	}
			// }).catch(err => {
			// 	this.log(err);
			// })
			this.$request(this.$urls.getAcquisition, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						for (let i = 0; i < response.data.length; i++) {
							if (response.data[i].type == 'UInt16' || response.data[i].type == 'Float32') {
								// this.iotRegData.push(response.data[i]);
								let data = {};
								if (this.deviceId) {
									/* data = {
										"deviceId": this.deviceId,
										"addr": response.data[i].addr,
										"startTime": this.starttime + ' 00:00:00',
										"endTime": this.endtime + ' 23:59:59',
									}; */
									this.collectionListAddr.push(response.data[i]);
									// this.collectionList.push(response.data[i])
								}
								// {id:41,{}}
							} else if (response.data[i].rw == true && response.data[i].type == 'Bool') {
								this.remoteList.push(response.data[i]);
								// this.iotData.push(response.data[i])
							} else if (response.data[i].type == 'Bool') {
								// this.iotData.push(response.data[i])
							}
							if (response.data[i].type == 'UInt16') {
								this.xinhaoNum = response.data[i].value;
							}
						}
						this.getDataCo();
						// this.optionData()
					}
				})
				.catch(err => {
					this.log(err);
				});
		},

		getDataCo() {
			this.showColl = false;

			for (let i = 0; i < this.collectionListAddr.length - 1; i++) {
				/*每次循环的时候都会把最后一个数字依次排在最后
					面，循环了几次，意味着后面已经排好了几个数，而
					那些已经排好的数也没必要再跟没排好的数进行比较
					即：数组长度length-已经循环的次数i*/
				for (let j = 0; j < this.collectionListAddr.length - 1 - i; j++) {
					if (this.collectionListAddr[j].addr > this.collectionListAddr[j + 1].addr) {
						let tmp = this.collectionListAddr[j];
						this.collectionListAddr[j] = this.collectionListAddr[j + 1];
						this.collectionListAddr[j + 1] = tmp;
						// console.log('i='+i,arr);
					}
				}
			}
			this.collectionList = new Array(this.collectionListAddr.length);

			let count = 0;
			for (let i = 0; i < this.collectionListAddr.length; i++) {
				let data = {};
				if (this.deviceId) {
					data = {
						deviceId: this.deviceId,
						addr: this.collectionListAddr[i].addr,
						startTime: this.starttime + ' 00:00:00',
						endTime: this.endtime + ' 23:59:59'
					};
				}

				this.$request(this.$urls.historyData, 'get', data, this.$store.state.token)
					.then(ies => {
						if (ies.code == 200) {
							let datas = ies.data;
							for (let a = 0; a < datas.length; a++) {
								datas[a].data = parseFloat(datas[a].data).toFixed(1);
							}
							this.collectionListAddr[i].staseList = datas;
						}

						this.collectionList[i] = this.collectionListAddr[i];
						count++;
						if (this.collectionListAddr.length == count) {
							this.showColl = true;
						}
					})
					.catch(err => {
						this.log(err);
					});
			}
		},
		getDeviceDataV2() {
			let that = this;
			// this.collectionList = [];
			// this.remoteList = [];
			this.iotData = [];
			this.iotRegData = [];
			this.iotOpenClose = [];

			let data = {};
			// data.deviceId = this.deviceData.id
			data.deviceId = this.deviceId;

			// this.isViewData.product.relayStartValue;
			/* if (this.isViewData.product.relayStartValue == null || this.isViewData.product.relayStartValue == "") {
					return;
				}

				if (this.isViewData.product.dataStartValue == null || this.isViewData.product.dataStartValue == "") {
					return;
				}
				if (this.isViewData.product.onOffStartValue == null || this.isViewData.product.onOffStartValue == "") {
					return;
				}
				if (this.isViewData.product.quantity == null || this.isViewData.product.quantity == "") {
					return;
				}

				let relayStartValue = parseInt(this.isViewData.product.relayStartValue);
				let dataStartValue = parseInt(this.isViewData.product.dataStartValue);
				let onOffStartValue = parseInt(this.isViewData.product.onOffStartValue);
				let quantity = parseInt(this.isViewData.product.quantity); */

			this.$request(this.$urls.getAcquisition, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						/* var b={}//设置用来调换位置的值
						for (let i = 0; i < response.data.length; i++) {
							console.log("!!!!!!!!!!")
							
							for(var j=i;j<response.data.length;j++){
								console.log(response.data[j].addr)
							        if(response.data[j].addr>response.data[j+1].addr){
							            b=response.data[j]
							            response.data[j]=response.data[j+1]
							            response.data[j+1]=b
							        }
							    }
							
						} */
						/* for(var i = 0; i < response.data.length; i++){
							//循环两两比较数组中的数字
							for(var j = 0; j < response.data.length; j++){
								//if判断，如果数组中的当前一个比后一个大，那么两个交换一下位置
								console.log(response.data[j].addr)
								if(response.data[j].addr > response.data[j + 1].addr){
									var tmp = response.data[j];
									response.data[j] = response.data[j + 1];
									response.data[j + 1] = tmp;
									// console.log('i='+i,arr);
								}
							}
						} */

						for (let i = 0; i < response.data.length - 1; i++) {
							/*每次循环的时候都会把最后一个数字依次排在最后
							面，循环了几次，意味着后面已经排好了几个数，而
							那些已经排好的数也没必要再跟没排好的数进行比较
							即：数组长度length-已经循环的次数i*/
							for (let j = 0; j < response.data.length - 1 - i; j++) {
								if (response.data[j].addr > response.data[j + 1].addr) {
									let tmp = response.data[j];
									response.data[j] = response.data[j + 1];
									response.data[j + 1] = tmp;
									// console.log('i='+i,arr);
								}
							}
						}
						for (let i = 0; i < response.data.length; i++) {
							/* if (response.data[i].addr >= relayStartValue && response.data[i].addr < (relayStartValue +
								quantity)) {
								this.iotData.push(response.data[i])
							}

							if (response.data[i].addr >= dataStartValue && response.data[i].addr < (dataStartValue + quantity)) {
								this.iotRegData.push(response.data[i])
							}

							if (response.data[i].addr >= onOffStartValue && response.data[i].addr < (onOffStartValue +
								quantity)) {
								this.iotOpenClose.push(response.data[i])
							} */
							if (response.data[i].type == 'Bool' && response.data[i].rw) {
								this.iotData.push(response.data[i]);
							}

							if (response.data[i].type == 'Float32' && response.data[i].rw == false) {
								this.iotRegData.push(response.data[i]);
							}

							if (response.data[i].type == 'Bool' && response.data[i].rw == false) {
								this.iotOpenClose.push(response.data[i]);
							}
						}

						this.iotData.forEach(function(item, index, arr) {
							/* if (that.iotRegData.length<=index) {
								that.iotData[index].regData = "0.0"
								that.iotData[index].unit = ""
							} else {
								that.iotData[index].regData = parseFloat(that.iotRegData[index].value).toFixed(1)
								// that.iotData[index].regData = that.iotRegData[index].value
								that.iotData[index].unit = (typeof that.iotRegData[index].unit == undefined || typeof that
										.iotRegData[index].unit == 'undefined') ?
									"" : that.iotRegData[index].unit

								that.iotData[index].regDataAddr = that.iotRegData[index].addr
							} */
							// console.log("222222222222")
							// console.log(index>that.iotRegData.length-1)
							if (
								index > that.iotRegData.length - 1 ||
								typeof that.iotRegData[index].value == undefined ||
								typeof that.iotRegData[index].value == 'undefined'
							) {
								that.iotData[index].regData = '';
								that.iotData[index].unit = '';
								that.iotData[index].regDataAddr = '';
							} else {
								that.iotData[index].regData = parseFloat(that.iotRegData[index].value).toFixed(1);
								// that.iotData[index].regData = that.iotRegData[index].value
								that.iotData[index].unit =
									typeof that.iotRegData[index].unit == undefined || typeof that.iotRegData[index].unit == 'undefined'
										? ''
										: that.iotRegData[index].unit;
								that.iotData[index].regDataAddr = that.iotRegData[index].addr;
							}

							that.iotData[index].oc = that.iotOpenClose[index].value;
							that.iotData[index].ocAddr = that.iotOpenClose[index].addr;
						});

						this.showMC = true;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},

		optionData() {
			let that = this;
			this.iotData.forEach(function(item, index, arr) {
				that.iotRegData.forEach(function(item2, index2, arr2) {
					if (item.addr + 20 == item2.addr) {
						that.iotData[index].regData = item2.value;
						that.iotData[index].unit = typeof item2.unit == undefined || typeof item2.unit == 'undefined' ? '' : item2.unit;
						return;
					}
				});

				if (typeof that.iotData[index].regData == undefined || typeof that.iotData[index].regData == 'undefined') {
					that.iotData[index].regData = '0.0';
					that.iotData[index].unit = '';
				}
			});

			this.remoteList.forEach(function(item, index, arr) {
				that.iotRegData.forEach(function(item2, index2, arr2) {
					if (item.addr + 20 == item2.addr) {
						that.remoteList[index].regData = item2.value;
						that.remoteList[index].unit = typeof item2.unit == undefined || typeof item2.unit == 'undefined' ? '' : item2.unit;
						return;
					}
				});

				/* console.log("remoteList===")
					console.log(typeof that.remoteList[index].regData == undefined || typeof that.remoteList[index].regData ==
						'undefined') */

				if (typeof that.remoteList[index].regData == undefined || typeof that.remoteList[index].regData == 'undefined') {
					that.remoteList[index].regData = '0.0';
					that.remoteList[index].unit = '';
				}
			});
		},
		// 获取远程控制
		getRemoteControl() {
			let data = {};
			data.deviceId = this.deviceData.deviceId;
			if (this.deviceData.slaveId == null) {
				this.deviceData.slaveId = '';
			}
			data.slaveId = this.deviceData.slaveId;
			data.type = '2';
			this.$request(this.$urls.getRemoteControl, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.remoteList = response.data;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 点击远程控制
		clickControl(item) {
			if (!(client && client.connected)) {
				this.connect();
			}
			if (this.isViewData.permissions.run) {
				let data = {};
				let regobj = {};
				data.regs = [];
				data.deviceId = this.deviceId;
				regobj.addr = item.addr;
				regobj.type = item.type;
				if (item.value == 'false') {
					regobj.value = 'true';
				} else {
					regobj.value = 'false';
				}
				data.regs[0] = regobj;
				let jsonData = JSON.stringify(data);
				this.$request(this.$urls.submitParameters, 'post', data, this.$store.state.token)
					.then(response => {
						if (response.code == 200) {
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: '操作成功'
							});
							// this.submitControl()
						} else if (response.code == 10104) {
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: '设备响应超时'
							});
							// this.submitControl()
						}
					})
					.catch(err => {
						this.log(err);
					});
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '请找管理员申请权限'
				});
			}
		},
		// 远程控制刷新
		submitControl() {
			this.remoteList = [];
			let data = {};
			data.deviceId = this.deviceData.id;
			this.$request(this.$urls.getAcquisition, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						for (let i = 0; i < response.data.length; i++) {
							if (response.data[i].rw == true && response.data[i].type == 'Bool') {
								this.remoteList.push(response.data[i]);
							}
						}
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 获取设备用户列表
		getUserList() {
			let data = {};
			data.deviceId = this.deviceData.id;
			this.$request(this.$urls.getUserList, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.userDeviceList = response.data;
						this.backupsuserList = response.data;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 获取定时任务列表
		getDingShiTasks() {
			let data = {};
			data.deviceId = this.deviceData.id;
			this.$request(this.$urls.getDingShiTasks, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.cacheJsonThingsModel();
						for (let i = 0; i < response.data.tasks.length; i++) {
							if (response.data.tasks[i].startHour.toString().length == 1) {
								response.data.tasks[i].startHour = '0' + response.data.tasks[i].startHour;
							}
							if (response.data.tasks[i].startMinute.toString().length == 1) {
								response.data.tasks[i].startMinute = '0' + response.data.tasks[i].startMinute;
							}
							if (response.data.tasks[i].stopHour.toString().length == 1) {
								response.data.tasks[i].stopHour = '0' + response.data.tasks[i].stopHour;
							}
							if (response.data.tasks[i].stopMinute.toString().length == 1) {
								response.data.tasks[i].stopMinute = '0' + response.data.tasks[i].stopMinute;
							}
							this.checkOptions3 = [];
							if (response.data.tasks[i].week.indexOf(1) != -1) {
								this.checkOptions3.push(this.checkOptions2[0]);
							} else {
								this.checkOptions3.push(this.checkOptions1[0]);
							}
							if (response.data.tasks[i].week.indexOf(2) != -1) {
								this.checkOptions3.push(this.checkOptions2[1]);
							} else {
								this.checkOptions3.push(this.checkOptions1[1]);
							}
							if (response.data.tasks[i].week.indexOf(3) != -1) {
								this.checkOptions3.push(this.checkOptions2[2]);
							} else {
								this.checkOptions3.push(this.checkOptions1[2]);
							}
							if (response.data.tasks[i].week.indexOf(4) != -1) {
								this.checkOptions3.push(this.checkOptions2[3]);
							} else {
								this.checkOptions3.push(this.checkOptions1[3]);
							}
							if (response.data.tasks[i].week.indexOf(5) != -1) {
								this.checkOptions3.push(this.checkOptions2[4]);
							} else {
								this.checkOptions3.push(this.checkOptions1[4]);
							}
							if (response.data.tasks[i].week.indexOf(6) != -1) {
								this.checkOptions3.push(this.checkOptions2[5]);
							} else {
								this.checkOptions3.push(this.checkOptions1[5]);
							}
							if (response.data.tasks[i].week.indexOf(0) != -1) {
								this.checkOptions3.push(this.checkOptions2[6]);
							} else {
								this.checkOptions3.push(this.checkOptions1[6]);
							}
							response.data.tasks[i].weeks = this.checkOptions3;
						}
						this.tasksList = response.data.tasks;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 获取定时任务物模型
		cacheJsonThingsModel() {
			this.cacheList = [];
			let data = {};
			data.deviceId = this.deviceData.id;
			this.$request(this.$urls.getAcquisition, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						for (let i = 0; i < response.data.length; i++) {
							if (response.data[i].rw == true && response.data[i].type == 'Bool') {
								this.cacheList.push(response.data[i]);
							}
						}
						// this.optionData()
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// // 渲染统计图
		// getStatistics() {
		// 	this.$refs.daychart.init(config => {
		// 		const chart = new F2.Chart(config);
		// 		chart.source(this.historyList, {
		// 			time: {
		// 				type: 'timeCat',
		// 				mask: 'HH:mm ss',
		// 				tickCount: 4,
		// 				range: [0, 1]
		// 			},
		// 			value: {
		// 				tickCount: 8,
		// 				min: 0
		// 			}
		// 		});
		// 		chart.axis('time', {
		// 			label: function label(text, index, total) {
		// 				const textCfg = {};
		// 				if (index === 0) {
		// 					textCfg.textAlign = 'left';
		// 				} else if (index === total - 1) {
		// 					textCfg.textAlign = 'right';
		// 				}
		// 				return textCfg;
		// 			}
		// 		});
		// 		chart.tooltip({
		// 			showCrosshairs: true,
		// 			triggerOn: ['touchstart', 'touchmove'], // tooltip 出现的触发行为，可自定义，用法同 legend 的 triggerOn
		// 			showTitle: false, // 是否展示标题，默认不展示
		// 			showTooltipMarker: true, // 是否显示 tooltipMarker
		// 			showXTip: { Boolean }, // 是否展示 X 轴的辅助信息
		// 			showYTip: { Boolean }, // 是否展示 Y 轴的辅助信息
		// 		});

		// 		chart.area()
		// 			.position('time*value')
		// 			.color('l(90) 0:#1890FF 1:#1890FF')
		// 			.shape('smooth');
		// 		chart.line()
		// 			.position('time*value')
		// 			.color('l(90) 0:#1890FF 1:#1890FF')
		// 			.shape('smooth');
		// 		chart.render();
		// 		return chart;
		// 	});
		// },
		// 告警通知列表
		getalarmList() {
			let data = {};
			data.deviceId = this.deviceData.deviceId;
			data.alertLevel = this.alarm;
			data.pageSize = 10;
			data.pageNum = this.alarmPageNum;
			this.$request(this.$urls.getalarmList, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						// this.alarmList = response.rows
						this.totals = response.total;
						for (let i = 0; i < response.rows.length; i++) {
							this.alarmList.push(response.rows[i]);
						}
					}
				})
				.catch(err => {});
		},
		alarmClick(num) {
			this.alarm = num;
			this.alarmTotal = 10;
			this.alarmList = [];
			this.alarmPageNum = 1;
			this.getalarmList();
		},
		onRefresh() {
			this.alarmTotal = 10;
			this.alarmList = [];
			this.alarmPageNum = 1;
			this.getalarmList();
			if (this._freshing) return;
			this._freshing = true;
			setTimeout(() => {
				this.triggered = false;
				this._freshing = false;
			}, 1000);
		},
		onRestore() {
			this.triggered = 'restore'; // 需要重置
		},
		onAbort() {},
		scrollAlarm(e) {
			if (this.alarmTotal > this.totals) {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '已加载所有'
				});
			} else {
				this.alarmTotal += 10;
				this.alarmPageNum++;
				setTimeout(() => {
					this.getalarmList();
				}, 500);
			}
		},
		// 主用户解绑
		userUnbind() {
			this.$request(this.$urls.userUnbind + this.deviceId, 'delete', {}, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 权限设置
		settingsButton(item) {
			console.log(item);
			this.$request(this.$urls.fenxiangDevice + this.deviceId, 'get', {}, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						if (this.isViewData.permissions.owner) {
							this.navigateTo(
								'/packageMine/details/authority?deviceId=' +
									this.deviceId +
									'&userId=' +
									item.userId +
									'&id=' +
									item.id +
									'&userName=' +
									item.username
							);
						} else {
							uni.showToast({
								icon: 'none',
								position: 'bottom',
								title: '权限不足'
							});
						}
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		// 分享
		fenxiangClick() {
			this.$request(this.$urls.fenxiangDevice + this.deviceId, 'get', {}, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.fenxiangToken = response.data.token;
					}
				})
				.catch(err => {
					this.log(err);
				});
		},
		onShareAppMessage: function(e) {
			var that = this;
			if (that.isViewData.permissions.owner) {
				var timestamp = Date.parse(new Date());
				timestamp = timestamp / 1000;
				return {
					title: '分享了1个设备',
					path:
						'/packageMine/main/share/index?fenxiangToken=' +
						that.fenxiangToken +
						'&timestamp=' +
						timestamp +
						'&deviceName=' +
						that.deviceData.name +
						'&deviceId=' +
						that.deviceData.id +
						'&userNames=' +
						that.userData.username,
					imageUrl: that.deviceData.ico + '?' + timestamp
				};
			} else {
				uni.showToast({
					icon: 'none',
					position: 'bottom',
					title: '权限不足'
				});
			}
		},
		// 联动控制
		getSceneList() {
			let data = {};
			data.deviceId = this.deviceData.deviceId;
			this.$request(this.$urls.getSceneList, 'get', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.sceneList = response.rows;
					}
				})
				.catch(err => {});
		},
		// 搜索框
		search(res) {
			this.keyword = res.value;
			if (res.value != '') {
				setTimeout(() => {
					// this.refreshList();
					let user = [];
					for (let i = 0; i < this.backupsuserList.length; i++) {
						if (this.backupsuserList[i].username.indexOf(this.keyword) != -1) {
							user.push(this.backupsuserList[i]);
						}
						if (i == this.backupsuserList.length - 1) {
							this.userDeviceList = user;
						}
					}
				}, 10);
			} else {
				this.getUserList();
			}
		},
		input(res) {
			this.keyword = res.value;
		},
		cancel(res) {
			this.keyword = '';
		},
		tasksChange(item) {
			let data = {};
			data.jobId = item.jobId;
			if (item.status == '0') {
				data.status = '1';
			} else {
				data.status = '0';
			}
			this.$request(this.$urls.getDingShiStatus, 'put', data, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.getDingShiTasks();
						uni.showToast({
							icon: 'none',
							position: 'bottom',
							title: '操作成功'
						});
					}
				})
				.catch(err => {
					// this.log(err);
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '操作失败'
					});
				});
		},
		// 删除定时任务
		deleteStatus(id) {
			console.log(id);
			let data = {};
			data.deviceId = this.deviceData.id;
			data.taskId = id;
			this.$request(this.$urls.deleteDingShi + 'deviceId=' + this.deviceData.id + '&taskId=' + id, 'delete', {}, this.$store.state.token)
				.then(response => {
					if (response.code == 200) {
						this.getDingShiTasks();
						uni.showToast({
							icon: 'none',
							position: 'bottom',
							title: '删除成功'
						});
					}
				})
				.catch(err => {
					// this.log(err);
					uni.showToast({
						icon: 'none',
						position: 'bottom',
						title: '删除失败'
					});
				});
		},
		staseChange(e, index) {
			// console.log(e)
			// e.value.thingsModelItem = {}
			// e.value.thingsModelItem.datatype = e.value.datatype
			// this.$delete(e.value, 'datatype');
			// e.value.value = JSON.parse(this.tasksList[index].actions)[0].value
			// let datalist = []
			// datalist.push(e.value)
			// this.tasksList[index].actions = JSON.stringify(datalist)
			// let data = this.tasksList[index]
			// this.$request(this.$urls.submitDingShi, 'put', data,
			// 	this.$store.state.token).then(response => {
			// 	if (response.code == 200) {
			// 		this.getDingShiTasks()
			// 		uni.showToast({
			// 			icon: 'none',
			// 			position: 'bottom',
			// 			title: '修改成功'
			// 		})
			// 	}
			// }).catch(err => {
			// 	// this.log(err);
			// 	uni.showToast({
			// 		icon: 'none',
			// 		position: 'bottom',
			// 		title: '修改失败'
			// 	})
			// })
		}
	}
};
</script>

<style scoped>
@import 'index.css';
</style>
